﻿using System;
using Expressions.Compiler;
using Expressions.Compiler.Interfaces;
using Excel.Expressions.Compiler;
using Excel.Expressions.Interfaces;

namespace Excel.Expressions
{
    internal partial class Nonterminals__
    {
        private static Rules _cell_expression_parameters()
        {
            return new Rules  
            {
                () => cell_reference[false],
                () => real_literal[false]
            };
        }
    }

    internal partial class Expressions
    {
        private static Func<CellExpression, IExpressionTree, CellExpression> _cell_expression_parameters()
        {
            return (a, b) =>
            {
                if (b[0].Context.Token.Equals(Nonterminals.cell_reference))
                {
                    return cell_reference[a, b[0]];
                }
                if (b[0].Context.Token.Equals(Nonterminals.real_literal))
                {
                    return new Number(b[0].Context.ToString());
                }
                throw new NotSupportedException("Input token is not supported");
            };
        }
    }
}
